package com.comac.print.component.app.service;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.comac.print.component.app.api.MasterPlateService;
import com.comac.print.component.app.cmd.MasterPlateCmd;
import com.comac.print.component.app.command.cmdExe.MasterPlateUploadMinIOCmdExe;
import com.comac.print.component.app.command.qryExe.MasterPlateUploadOssQryExe;
import com.comac.print.component.app.dto.MasterPlateDTO;
import com.comac.print.component.app.gatewayimpl.database.dataobject.MasterPlateDO;
import com.comac.print.component.app.page.PageResponse;
import com.comac.print.component.app.qry.MasterPlateListQry;
import com.comac.print.component.app.qry.VersionListQry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MasterPlateServiceImpl implements MasterPlateService {

//    @Autowired
//    private MasterPlateUploadOssCmdExe masterPlateUploadOssCmdExe;

    @Autowired
    private MasterPlateUploadOssQryExe masterPlateUploadOssQryExe;
    @Resource
    private MasterPlateUploadMinIOCmdExe masterPlateUploadMinIOCmdExe;

    @Override
    public SingleResponse<String> uploadToOss(MultipartFile file) {
        return masterPlateUploadMinIOCmdExe.execute(file);
    }

    @Override
    public Response saveMasterPlate(MasterPlateCmd masterPlateCmd) {
        return masterPlateUploadMinIOCmdExe.saveMasterPlate(masterPlateCmd);
    }

    @Override
    public PageResponse<MasterPlateDTO> qryMasterPlateList(MasterPlateListQry masterPlateListQry) {
        return masterPlateUploadOssQryExe.qryMasterPlateList(masterPlateListQry);
    }
    @Override
    public List<MasterPlateDTO> versionList(VersionListQry versionListQry) {
        List<MasterPlateDO> masterPlateDOS = masterPlateUploadOssQryExe.versionList(versionListQry);
        return BeanUtil.copyToList(masterPlateDOS, MasterPlateDTO.class);
    }
    @Override
    public Response masterPlateDelete(MasterPlateCmd masterPlateCmd) {
//        return masterPlateUploadOssCmdExe.masterPlateDelete(masterPlateCmd);
        return masterPlateUploadMinIOCmdExe.masterPlateDelete(masterPlateCmd);
    }

}
